{% extends 'feedback/base.html' %}
{% block title %} 
    Список нарядов
{% endblock %}
{% block content %}
<h2>Список нарядов</h2>
<button type="button" class="btn btn-primary" _="on click go to url {% url 'naryad_add' %}">Добавить наряд</button>
{% comment %} <button><a href="{% url 'naryad_add' %}">Добавить наряд</a></button> {% endcomment %}
<div class="container-fluid">
<table class="table table-sm">
    <thead>
        <tr>
            <th scope="col">Н.Н.</th>
            <th scope="col">ФИО</th>
            <th scope="col">Доктор</th>
            <th scope="col">Техник</th>
            <th scope="col">Литейщик</th>
            <th scope="col">Полировщик</th>
            <th scope="col">CAD/CAM</th>
            <th scope="col">Передать</th>
            <th scope="col">Подробно</th>
        </tr>
    </thead>
</table>
{% for naryad in naryad_list %}

<form method="POST">
    {% csrf_token %}
    <input type="submit" formaction="default_url_when_press_enter" style="visibility: hidden; display: none;">
{% if naryad.images.all or naryad.kom_etap %}
    <details>
        <summary>
    <table class="table table-success table-striped table-sm">
    {% else %}
    <table class="table table-sm">
    {% endif %}
    <tbody>
        <tr>
            <td>
                <a href="/naryad_upd/{{ naryad.id }}"> {{ naryad.nkv }}</a>
            </td>
            <td>
                {{ naryad.patient.cut_fio }}
            </td>
            <td>
                {{ naryad.doctor}}
            <td>
                <select class="form-control" id="select_tech" name="select_tech">
                    <option value="0">Отсутствует</option>
                    {% for tech in tech_list %}
                        <option value="{{ tech.id }}" {% if tech.id == naryad.tech_id %} selected {% endif %}>{{ tech }}</option>
                    {% endfor %}
            </td>
            <td>
                <select class="form-control" id="select_lit" name="select_lit">
                    <option value="0">Отсутствует</option>
                    {% for lit in lit_list %}
                        <option value="{{ lit.id }}" {% if lit.id == naryad.lit_id %} selected {% endif %}>{{ lit }}</option>
                    {% endfor %}
            <td>
                <select class="form-control" id="select_pol" name="select_pol">
                    <option value="0">Отсутствует</option>
                    {% for pol in pol_list %}
                        <option value="{{ pol.id }}" {% if pol.id == naryad.pol_id %} selected {% endif %}>{{ pol }}</option>
                    {% endfor %}
            </td>
            <td>
                <select class="form-control" id="select_cad" name="select_cad">
                    <option value="0">Отсутствует</option>
                    {% for cadcam in cadcam_list %}
                        <option value="{{ cadcam.id }}" {% if cadcam.id == naryad.cad_id %} selected {% endif %}>{{ cadcam }}</option>
                    {% endfor %}
            </td>
            <td>
                <button formaction="next_etap/{{ naryad.id }}/35" class="btn btn-primary">В работу</button>
            </td>
            <td>
                <button formaction="set_sdl/{{ naryad.id }}" class="btn btn-primary">Дополнить</button>
            </td>
        </tr>
    </tbody>
</table>
</form>

    {% if naryad.images.all or naryad.kom_etap %}
        </summary>
    {% endif %}
    {% for photo in naryad.images.all %}
        <td><img src="{{ photo.img.url }}" style="width:100px;height:100px;" alt=""></td>
    {% endfor %}
    {% if naryad.images.all or naryad.kom_etap %}
        </details>
    {% endif %}

{% endfor %}
</div>
{% endblock %}